//给文件取个别名
@file:JvmName("Hero")

import java.io.IOException

fun main() {
    val jJava = JJava()
    println(jJava.utterGreeting())

    //平台类型
    val level = jJava.determineFriendshipLevel()
    level?.toLowerCase()

    jJava.hitPoints= 90
    //所有映射类型都会重新映射回对应的java类型
    //jJava.hitPoint会直接调getHitPoints
    println(jJava.hitPoints.javaClass)

    handOverFood()

    //kt不是强制性抛异常
    jJava.extendHandInFriendship()
}

fun makeProclamation() = "greetings, beast!"

//调用者可以指定英雄左手或右手拿什么食物，或者使用默认的配置-左手拿浆果，右手拿牛肉
@JvmOverloads
fun handOverFood(leftHand:String = "berries", rightHand:String = "beef") {
    println("hhhh...you hand over some delicious $leftHand and $rightHand")
}

@Throws(IOException::class)
fun acceptApology() {
    throw IOException()
}

//添加一个translator的函数类型，接受一个字符串，将其改为小写字母，再大写第一个字母，最后打印结果
val translator = { utterance:String ->
    println(utterance.toLowerCase().capitalize())

}